Optimizing meshes

You can improve the performance of your Kanzi application by reducing the amount of vertex data in the meshes the application shows. When you reduce the amount of mesh vertex data, the size of the kzb file and the amount of GPU memory required at runtime decrease.

Editing mesh attributes

You can change vertex data of a mesh using the Mesh Attributes Editor.
For example, you can use the Mesh Attributes Editor to remove the attributes you do not use and select the optimal data type for your needs.

To edit mesh attributes:

  1. In the Library > Meshes right-click the mesh you want to edit and select Open Mesh Attributes Editor.
    In the Mesh Attributes Editor the Import table shows the semantic, number of dimensions, and data range of the attributes of the mesh as you imported it to Kanzi Studio
  2. In the Mesh Attributes Editor in the Export table set these attributes to control how Kanzi Studio exports the mesh to the kzb file:

    The status bar at the bottom of the Mesh Attributes Editor shows the size of the mesh vertex data if you export the kzb file with the values you have currently set in the Export table.

Setting the correct size of vertex cache

GPUs have a vertex cache of a certain size. Accessing mesh vertices from the cache is an order of magnitude faster than accessing vertices from elsewhere in the memory. You can optimize the mesh data for a certain cache size by reordering vertices and indices in the vertex buffer so that the amount of cache hits is optimal.

For example, a 16-byte vertex cache can store Position + Normal + Texcoord (XYZ * 2 + XYZ * 2 + UV * 2), but is too small to store Position + Normal + Texcoord + Color.

To set the correct size of vertex cache for your target hardware:

  1. Find out the vertex cache size of your target hardware.
  2. In Kanzi Studio select Project > Properties and in the Properties in the Binary Export property category set:

Setting the optimal data type for mesh attributes

To optimize your meshes, set for each mesh attribute the data type that occupies the least amount of space while providing enough visual accuracy for your needs. Kanzi uses the data type when storing the attribute to the GPU memory and exporting it to the kzb file. When you use data types that occupy less space, the size of the kzb file and the amount of GPU memory required at runtime decrease. See Data types for mesh attributes.

To set the optimal data type for a mesh attribute:

  1. In the Library > Meshes right-click the mesh you want to edit and select Open Mesh Attributes Editor.
  2. In the Mesh Attributes Editor in the Import table check the values in the Data Range column for the attribute the data type of which you want to set.
    Kanzi Studio marks the data ranges of the different dimensions of a mesh attribute with different colors.
  3. In the Mesh Attributes Editor in the Export table use the dropdown in the Data Type column to set the export data type.
    When setting the data type, keep in mind:

Data types for mesh attributes

This table lists the mesh attribute data types that Kanzi supports.

      Availability for Target Graphics API
Data type Description Range OpenGL ES 2.0 OpenGL ES 2.0 Extension Pack OpenGL ES 3
Float Single-precision floating-point (32 bits)   x x x
Half-float Half-precision floating-point (16 bits)     x x
8_SNORM 8-bit signed normalized -1.0f ... 1.0f x x x
8_UNORM 8-bit unsigned normalized 0.0f ... 1.0f x x x
16_SNORM 16-bit signed normalized -1.0f ... 1.0f x x x
16_UNORM 16-bit unsigned normalized 0.0f ... 1.0f x x x
8_SINT 8-bit signed integer -128 ... 127     x
8_UINT 8-bit unsigned integer 0 ... 255     x
16_SINT 16-bit signed integer -32 768 ... 32 767     x
16_UINT 16-bit unsigned integer 0 ... 65,535     x
32_SINT 32-bit signed integer -2 147 483 648 ... 2 147 483 647     x
32_UINT 32-bit unsigned integer 0 ... 4 294 967 295     x
32_SNORM 32-bit signed normalized -1.0f ... 1.0f     x
32_UNORM 32-bit unsigned normalized 0.0f ... 1.0f     x
2_10_10_10_SNORM_PACK32 Four-component 32-bit packed signed normalized with:
  • 10-bit X component in bits 0..9
  • 10-bit Y component in bits 10..19
  • 10-bit Z component in bits 20..29
  • 2-bit W component in bits 30..31
(-1, -1, -1, -1) ... (1, 1, 1, 1)     x
2_10_10_10_UNORM_PACK32 Four-component 32-bit packed unsigned normalized with:
  • 10-bit X component in bits 0..9
  • 10-bit Y component in bits 10..19
  • 10-bit Z component in bits 20..29
  • 2-bit W component in bits 30..31
(0, 0, 0, 0) ... (1, 1, 1, 1)     x
           

See also

Using meshes

Meshes best practices

Editing shaders

Using OpenGL ES 3.0 in Kanzi